<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<HTML>
<HEAD>
	<title>文件上传、下载</title>
<script type="text/javascript">

<%
	// 主表主键
	String tableid = request.getParameter("tableid");
	session.setAttribute("tableid", tableid);
	
	// 主表字段名
	String colname = request.getParameter("colname");
	session.setAttribute("colname", colname);
	
	// 是否是图片
	String imageflag = request.getParameter("imageflag");
	session.setAttribute("imageflag", imageflag);	
	
	// 上传路径
	String filepath = request.getParameter("filepath");
	session.setAttribute("filepath", filepath);	
	
%>
Ext.onReady(function(){  
    // 主面板（已有tab）   	
     tabPanel = new Ext.TabPanel({   
        region:'center',   
        deferredRender:false,   
        autoScroll: true,    
        margins:'0 4 4 0',   
        activeTab:0,   
        
        //下面是比上面例子新增的关键右键菜单代码
        listeners:{
                 //传进去的三个参数分别为:这个tabpanel(tabsDemo),当前标签页,事件对象e
                "contextmenu":function(tdemo,myitem,e){
                            menu=new Ext.menu.Menu([{
                                     text:"关闭当前页",
                                     handler:function(){
                                        
                                        if(myitem.id!='list_tabPanel'){
                                          tdemo.remove(myitem);
                                        }
                                        
                                     }
                            },{
                                     text:"关闭其他所有页",
                                     handler:function(){
                                        //循环遍历
                                        tdemo.items.each(function(item){
                                             if(item.closable&&item!=myitem)
                                             {
                                                //可以关闭的其他所有标签页全部关掉
                                                tdemo.remove(item);
                                             }
                                        });
                                     }
                            }]);
                            //显示在当前位置
                            menu.showAt(e.getPoint());
                 }
        },
        

        items:[{   
            id:'list_tabPanel',   
            contentEl:'tabs',   
            title: '上传、下载附件',   
            closable:false,   
            autoScroll:true,
            html:'<iframe id="list_frame" src= "<%= request.getContextPath()%>/file!getFileListByTableid.do" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>'    
   
        }]      
    });   

    //===========================================
    //  配置视图viewport   
    viewport = new Ext.Viewport({   
           layout:'border',   
           items:[tabPanel]});   
   
  
    
    // 映射连接的id到函数   
    var count = 0;   
    var actions = {   
        'create' : function(){   
            addTab("New Tab",'loripsum.html');   
        },   
        'use' : function(){  
        //window.alert("count=="+count); 
            // 演示页之间的轮换   
            updateTab('tab1','替换' + count + ' 次','sample'+(count%2)+'.html');   
            count++;                   
        }   
    };   
    
    function doAction(e, t){   
        e.stopEvent();   
        actions[t.id]();   
    } 
});    

   var tab_num=0;
   // 在中间的面板加入tab   
    function addTab(tabTitle, targetUrl){   
        
        tab_num++;

        var idstr='detail_tabPanel'+tab_num;
        
        targetUrl=targetUrl+"&tabPanelid="+idstr;
 
        tabPanel.add({   
	        id:idstr,   
	        title: tabTitle,   
	        iconCls: 'tabs',   
	        //autoLoad: {url: targetUrl, callback: this.initSearch, scope: this},   
	        html:'<iframe src="'+targetUrl+'" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>',  
	        closable:true  
       }).show();   
    }
  
    function removeItem(tabId){

        var tab = tabPanel.getItem(tabId);   
        if(tab){   
            tabPanel.remove(tab);
        }else{
         	alert("页面不存在");
        }
        refushList();
    }  
</script>  
</HEAD>

<body class="standard" topmargin="0" leftmargin="0"> 
    
<ul id="actions" class="x-hidden">   
    <li>   
        <a id="use" href="#">Use Existing Tab</a>   
    </li>   
    <li>   
        <a id="create" href="#">Create New Tab</a>   
    </li>   
</ul>   
    
<div id="tabs"></div>   
</body>   
</html>  